03. Implement a CursorAdapter
Implement a CursorAdapter
Question:
Start Quiz:
Solution:
Implement a CursorAdapter
Use code from this gist to help you get started
Refer to this Codepath tutorial
Advanced note:
Are you wondering how the ArrayAdapter’s getView() method relates to the CursorAdapter’s newView() and bindView() methods?
Check out the Android source code for the CursorAdapter class. The getView() method still exists, but it actually calls newView() and bindView() based on whether there is a list item view that can be recycled or not. (If convertView is null, we need to create a brand new list item. If convertView is not null, we can recycle the old list item view.)
Hence, as a developer, we don’t need to override the CursorAdapter getView() method. We can just override the newView() and bindView() methods, and the adapter will take care of everything from there!
The solution code changes can be seen here.